<%@ Language=VBScript%>
<%
	Session("FormName")="F14"
%>
<!--#include file="..\CheckSession.inc"-->
<!--#include file=..\getFormName.inc-->
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>
<!--#include file="..\jvGrid.inc"-->
<!--#include file=..\vbFunction.inc-->
<!--#include file="..\pageSelected.inc"-->
<%		
	Set ClsFun =server.CreateObject("Vinalines.ClsFunction")	
	CheckAdd=request.form("CheckAdd")

	Dim bLink 
	mode=Request("mode")
	bComm=Request("bComm")
	bMa=Request("bMa")
	bMacu=Request("bMacu")

	if bComm="detail" then		
		bMa=Request("bMa")
		bMacu=Request("bMacu")
		sSQL="Select * from doitac where madoitac Like '"& bMa &"'"
		Set RecDL=server.CreateObject("ADODB.Recordset")
		RecDL.CursorType=3
		RecDL.CacheSize=5
		RecDL.Open sSQL,Conn
		if RecDL.RecordCount then	
			bTen=RecDL("Tendoitac")
			bDiachi=RecDL("diachi")
			bPhone=RecDL("Phone")
			bFax=RecDL("Fax")
			bEmail=RecDL("Email")
			Loaitim=request("Loaitim")
			bsearch=request("bsearch")
		end if
		RecDL.Close
		set RecDL=nothing
	else
		bTen=Request("bTen")
		bDiachi=Request("bdiachi")
		bPhone=Request("bPhone")
		bFax=Request("bFax")
		bEmail=Request("bEmail")
		Loaitim=request("Loaitim")
		bsearch=request("bsearch")
	end if	
	Dim bTempComm
	dim bMsg
	Dim Msg	
	if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin") then
		Select Case bComm
			Case "add"
				if not KTMa(bMa,bComm) then
					sSQL="Insert into Doitac(madoitac,tendoitac,diachi,phone,fax,email)values('"& ClsFun.ModiString(bMa) &"','"& ClsFun.ModiString(bTen) &"','"& ClsFun.ModiString(bdiachi) &"','"& ClsFun.ModiString(bPhone) &"','"& ClsFun.ModiString(bFax) &"','"& ClsFun.ModiString(bEmail) &"')"
					Conn.Execute sSQL	
				else
					Msg="M&#227; &#273;&#227; t&#7891;n t&#7841;i"
					bMsg="ma"
				end if
			case "delete"	
				'set RecKT=server.CreateObject("ADODB.Recordset")
				'RecKT.CursorType=3
				'RecKT.CacheSize=5
				'ssql="Select IDdoitac from NOI_NHAN where IDDOITAC = '"& ClsFun.ModiString(bma) &"'"
				'RecKT.Open ssql,Conn
				'if RecKT.RecordCount<=0 then
				'	RecKT.close
				'	ssql="Select doitac from VTDen where Doitac = '"& ClsFun.ModiString(bma) &"'"
				'	RecKT.Open ssql,Conn
				'	if RecKT.RecordCount<=0 then
						sSQL="Delete from Doitac Where madoitac Like '"& ClsFun.ModiString(bMa) &"'"
						Conn.Execute sSQL	
				'	else
				'		Msg="&#208;&#7889;i t&#225;c &#273;ang s&#7917; d&#7909;ng kh&#244;ng th&#7875; xo&#225; &#273;&#432;&#7907;c !"					
				'	end if				
				'else
				'	Msg="&#208;&#7889;i t&#225;c &#273;ang s&#7917; d&#7909;ng kh&#244;ng th&#7875; xo&#225; &#273;&#432;&#7907;c !"
				'end if
				'RecKT.Close
				'set RecKT=nothing	
			case "edit"
				if not KTMa(bMa,"edit") then
					on error resume next
					Conn.BeginTrans
					sSQL="Update Doitac set madoitac='"& ClsFun.ModiString(bma) _
									&"',tendoitac='"& ClsFun.ModiString(bTen) _
									&"',diachi='"& ClsFun.ModiString(bdiachi) _
									&"',phone='"& ClsFun.ModiString(bPhone) _
									&"',fax='"& ClsFun.ModiString(bFax) _
									&"',email='"& ClsFun.ModiString(bEmail) _
									&"' Where madoitac Like '" & ClsFun.ModiString(bMacu) & "'"
					Conn.Execute sSQL
					sSQL="Update VTDen set doitac='"& ClsFun.ModiString(bma)  &"' Where doitac Like '" & ClsFun.ModiString(bMacu) & "'"
					Conn.Execute sSQL
					if Err.number then
						Conn.RollbackTrans
					else
						Conn.CommitTrans
					end if
					Err.Clear
				else
					Msg="M&#227; &#273;&#227; t&#7891;n t&#7841;i"
					bMsg="ma"
				end if
		End Select
	End if
	Set Rec=server.CreateObject("ADODB.Recordset") 
	rec.CursorType = 3
	rec.CacheSize=5		
	'Pha tim kiem
	select case request("bComm")
		case "search"	
			ssql="Select * from doitac where tendoitac like '%"& ClsFun.ModiString(bsearch) & "%' order by Madoitac"
		case else
			Loaitim=""
			bsearch=""
			ssql="Select * from doitac order by Madoitac"
	end select
	Dim nRecCount	' Number of records found
	Dim nPageCount	' Number of pages of records we have
	Dim nPage	' Current page number
	nPage=CLng(request("Page"))	
	if nPage="" then nPage=1
	rec.Open ssql,Conn
	if  rec.EOF and rec.BOF then
		nPageCount=0
	end if	
%>
<%if Msg<>"" then%>
  <% if bMsg="ma" then %>
			<center><font color=red size=3 face='Times new roman'>M&#227; &#273;&#7889;i t&#225;c: <%=bma%> &#273;&#227; t&#7891;n t&#7841;i</font></center>
	<%else%>
		<center><font color=red size=3 face='Times New Roman'><%=Msg%></font></center>
   <%end if%>
<%end if%>
<!--#include file="..\jvfunction.inc"-->
<script language=VBScript runat=server>
	'Kiem tra ma trung
	Function KTMa(bValue,loai)
		KTMa=false
		if loai="add" then
			ssql="Select * from doitac where Madoitac like '"& trim(ClsFun.ModiString(bValue)) &"'"
			Set RecTemp=server.CreateObject("ADODB.Recordset") 
			RecTemp.Open ssql,Application("StrConn")
			if (not rectemp.BOF) and (not RecTemp.EOF) then
				KTMa=True
			end if
			set RecTemp=nothing
		end if
		if loai="edit" then
			if bMacu<>bValue then
				ssql="Select * from doitac where Madoitac like '"& trim(ClsFun.ModiString(bValue)) &"'"
				Set RecTemp=server.CreateObject("ADODB.Recordset") 
				RecTemp.Open ssql,Application("StrConn")
				if (not rectemp.BOF) and (not RecTemp.EOF) then
					KTMa=True
				end if
				set RecTemp=nothing
			end if		
		end if
	End function
	'Kiem tra ten trung
	Function KTTen(bValue)
		KTTen=false
		ssql="Select * from doitac where Tendoitac like '"& ClsFun.ModiString(bValue) &"'"
		Set RecTemp=server.CreateObject("ADODB.Recordset") 
		RecTemp.Open ssql,Application("StrConn")
		if (not rectemp.BOF) and (not RecTemp.EOF) then
			KTTen=True
		end if
		Set  RecTemp=nothing
	End function	
 
	Sub KTQuyen()
		if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)<>"1" or not Session("IsAdmin") then		
			nhom.CmdAdd.disabled= true
		end if
	End sub
Function Paging(ByVal intPage, ByVal intPageCount, ByVal intRecordCount)
	Dim strQueryString
	Dim strScript
	Dim intStart
	Dim intEnd
	Dim strRet
	Dim i

	If intPage > intPageCount Then
		intPage = intPageCount
	ElseIf intPage < 1 Then 
		intPage = 1
	End If
	
	If intRecordCount = 0 Then
		'strRet = "No Records Found"
	ElseIf intPageCount = 1 Then
		'strRet = "End Of Hits"
	Else
		For i = 1 To Request.QueryString.Count
			If LCase(Request.QueryString.Key(i)) <> "page" Then
				strQueryString = strQueryString & "&" 
				strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Key(i)) & "=" 
				strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Item(i))
			End If
		Next

		For i = 1 To Request.Form.Count
			If LCase(Request.Form.Key(i)) <> "page" Then
				strQueryString = strQueryString & "&" 
				strQueryString = strQueryString & Server.URLEncode(Request.Form.Key(i)) & "=" 
				strQueryString = strQueryString & Server.URLEncode(Request.Form.Item(i))
			End If
		Next

		If Len(strQueryString) <> 0 Then
			strQueryString = "?" & Mid(strQueryString, 2) & "&"
		Else
			strQueryString = "?"
		End If

		strScript = Request.ServerVariables("SCRIPT_NAME") & strQueryString
	
		If intPage <= 10 Then
			intStart = 1
		Else
			If (intPage Mod 10) = 0 Then
				intStart = intPage - 9
			Else
				intStart = intPage - (intPage Mod 10) + 1
			End If
		End If

		intEnd = intStart + 9
		If intEnd > intPageCount Then intEnd = intPageCount
	
		'strRet = "Page " & intPage & " of " & intPageCount & ": "
	
		If intPage > 10 Then 
			strRet = strRet & "<a href=""" & strScript
			strRet = strRet & "page=" & intPage - 10 
			strRet = strRet & """><IMG border=0 SRC=../images/prev.gif></a> "
		End If
	
		For i = intStart To intEnd
			If i = intPage Then
				strRet = strRet & "<b><font color=A90A08>" & i & "</font></b> "
			Else
				strRet = strRet & "<a href=""" & strScript
				strRet = strRet & "page=" & i 
				strRet = strRet & """>" & i & "</a>"
				If i <> intEnd Then strRet = strRet & " "
			End If
		Next
	
		If intPage <> intPageCount and intPageCount > 10 Then
			strRet = strRet & " <a href=""" & strScript
			strRet = strRet & "page=" & intPage + 10 
			strRet = strRet & """><IMG border=0 SRC=../images/next.gif></a> "
		End If
	End If
	
	Paging = strRet
End Function
</script>

<script language=VBScript  runat="server">
</script>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function ChangePage(){
	strURL=nhom.page.value;
	window.nhom.target="right";
	window.nhom.action=strURL;
	window.nhom.submit();	
}

function SetFocus(){
	if (!nhom.TxtMa.disabled){
		document.nhom.TxtPhone.focus();
	}else{
		document.nhom.CmdSearch.focus();
	}
}


function KTnhap(){
	if (nhom.TxtMa.value==""){
		alert("Bạn cần phải nhập mã");
		nhom.TxtMa.focus();
		return false;
	}
	if(daucach(nhom.TxtMa.value)){
		alert("Mã không cho chứa ký tự đặc biệt (',space)");
		nhom.TxtMa.focus();
		return false;
	}
	if (nhom.TxtTen.value==""){
		alert("Bạn cần phải nhập tên");
		nhom.TxtTen.focus();
		return false;
	}
	return true;
}
function CmdAdd_onclick() {
	nhom.TxtMa.value="<%=TaoMa("madoitac","doitac")%>"
	//nhom.TxtMa.value="";
	nhom.TxtTen.value="";
	nhom.TxtDiachi.value="";
	nhom.TxtPhone.value="";
	nhom.TxtFax.value="";
	nhom.CheckAdd.disabled=false;
	nhom.CheckAdd.checked=true;
	cmdenable(false);
	Unlockdata();
	nhom.TxtPhone.focus();
	nhom.sua.value="2";
}

function cmdenable(bvalue){
	if (bvalue){
		if ("<%= Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)%>"=='1'||"<%= Session("IsAdmin") %>".toLowerCase()=='true'){
			nhom.CmdAdd.disabled= false;
		}			
		else{
			nhom.CmdAdd.disabled= true;		
		}
		nhom.CmdDelete.disabled= false;
		nhom.CmdEdit.disabled= false;
		nhom.CmdSearch.disabled= false;
		nhom.CmdCancel.disabled= true;
		nhom.CmdOK.disabled= true;	
	}
	else {
		nhom.CmdAdd.disabled= true;
		nhom.CmdDelete.disabled= true;
		nhom.CmdEdit.disabled= true;
		nhom.CmdSearch.disabled= true;
		nhom.CmdCancel.disabled= false;
		nhom.CmdOK.disabled= false;
	}	
	nhom.CmdSearch.value="Tì<u>m</u> kiếm";
}

function CmdCancel_onclick() {
	cmdenable(true);
	nhom.CmdDelete.disabled= true;
	nhom.CmdEdit.disabled= true;
	nhom.CheckAdd.checked=false;
	nhom.CheckAdd.disabled=true;
	Lockdata();
	nhom.TxtDiachi.value="";
	nhom.TxtEmail.value="";
	nhom.TxtFax.value="";
	nhom.TxtMa.value="";
	nhom.TxtPhone.value="";
	nhom.TxtTen.value="";
	
}

function Lockdata(){
	nhom.TxtMa.disabled=true;
	nhom.TxtDiachi.disabled=true;
	nhom.TxtPhone.disabled=true;
	nhom.TxtFax.disabled=true;
	nhom.TxtTen.disabled=true;
	nhom.TxtEmail.disabled=true;
}
function Unlockdata(){
	nhom.TxtMa.disabled=false;
	nhom.TxtDiachi.disabled=false;
	nhom.TxtPhone.disabled=false;
	nhom.TxtFax.disabled=false;
	nhom.TxtTen.disabled=false;
	nhom.TxtEmail.disabled=false;
}


function displaydata(){
	nhom.TxtMa.value="";
	nhom.TxtTen.value="";
	nhom.TxtDiachi.value="";
	return;
}


function window_onload() {
//	CmdCancel_onclick();	
}

function CmdExit_onclick() {
//	window.navigate("<%= Session("LastForm")%>");
}

function CmdDelete_onclick() {
	if (nhom.TxtMa.value==""){
		alert("Hãy chọn thông tin cần xóa");
		return ;
	}
	if(!confirm("Có muốn xóa không ?")){
		return false;	
	}
	ma=nhom.TxtMa.value;
	cp=nhom.cPage.value
	b="frmdoitac.asp?Page="+cp+"&bma="+ma+"&bComm=delete"					
	window.nhom.target="right"
	window.nhom.action=b;
	window.nhom.submit();
	//window.navigate(b);
}
function CmdEdit_onclick() {
	if (nhom.TxtMa.value==""){
		alert("Hãy chọn thông tin cần sửa");
		return ;
	}
	cmdenable(false);
	Unlockdata();
	nhom.TxtMa.focus();
	<%bTempComm="edit"%>
	nhom.sua.value="1";
	nhom.Macu.value=nhom.TxtMa.value;
}
function CmdOK_onclick() {
	if (KTnhap()){
		cmdenable(true);
		Lockdata();
		ma=nhom.TxtMa.value;
		ten=nhom.TxtTen.value;
		diachi=nhom.TxtDiachi.value
		phone=nhom.TxtPhone.value
		fax=nhom.TxtFax.value
		email=nhom.TxtEmail.value
		macu=nhom.Macu.value
		bc=nhom.sua.value
		cp=nhom.cPage.value
		if (bc=="1"){
			b="frmdoitac.asp?Page="+cp+"&bMacu="+macu+"&bma="+ma+"&bTen="+ten+"&bdiachi="+diachi+"&bphone="+phone+"&bfax="+fax+"&bemail="+email+"&bComm=edit"		
		}
		else {
			b="frmdoitac.asp?Page="+cp+"&bma="+ma+"&bTen="+ten+"&bdiachi="+diachi+"&bphone="+phone+"&bfax="+fax+"&bemail="+email+"&bComm=add"					
		}
		window.nhom.target="right"
		window.nhom.action=b;
		window.nhom.submit();
		//window.navigate(b);
	}
}

function CmdLoc_onclick() {
	Unlockdata();
	nhom.TxtMa.focus();
//	nhom.sua.value="2";
}


function CmdRefresh_onclick() {
	cp=nhom.cPage.value;
	lnk="frmdoitac.asp?Page="+cp;
	window.navigate(lnk);
}

function window_onload() {
	//CmdCancel_onclick();
}

function TxtSearch_onclick() {
}

function CmdSearch_onclick() {
	nhom.CmdAdd.disabled=true;
	nhom.CmdCancel.disabled=false;
	nhom.CmdEdit.disabled=true;
	nhom.CmdDelete.disabled=true;
	if (nhom.TxtTen.disabled){
		nhom.CmdSearch.value="Tì<u>m</u>";
		Unlockdata()
		nhom.TxtDiachi.value="";
		nhom.TxtMa.value="";
		nhom.TxtTen.value="";
		nhom.TxtFax.value="";
		nhom.TxtPhone.value="";
		nhom.TxtEmail.value="";
		Lockdata()
		nhom.TxtTen.disabled=false;
		nhom.TxtTen.value="";
		nhom.TxtTen.focus();
		return false;
	}
	value=nhom.TxtTen.value;
	blink="frmdoitac.asp?bsearch="+value+"&bComm=search";
	window.nhom.action=blink;
	window.nhom.target="right"
	window.nhom.submit();	
}

function CmdPrint_onclick() {
	window.nhom.target="new";
	window.nhom.action="../IN/FrmIn.asp?bIn=doitac";
	window.nhom.submit();
	
}

//-->
</SCRIPT>
<LINK href="../styles/styles.css" type=text/css rel=STYLESHEET>
<body  bgcolor=#F8F9D9 topmargin="0" leftmargin="0" style="font-family:times new roman" onload="SetFocus()">
<form name="nhom" method="POST">
	<input type="hidden" name="sua" value="">
	<input type="hidden" name="Macu" value="">
	<input type="hidden" name="cPage" value="<%=nPage%>">
	<input type="hidden" name="strURL" value="">
<p align=center><b><font FACE="Times New Roman" size="3">CẬP NHẬT TỔ CHỨC ĐỐI TÁC</font></b>
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" bgcolor="#BDD5D0" bordercolor="#111111">

<% if CheckAdd="ON" then%>
  <tr>
    <td width="17%">
    		<Button disabled name="CmdAdd" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><U>T</U>hêm</Button></td>
    <td width="17%">
    		<Button disabled name="CmdDelete" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><U>X</U>óa</Button></td>
    <td width="17%">
    		<Button disabled name="CmdEdit" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><U>S</U>ửa</Button></td>
    <td width="17%">
    		<Button name="CmdOK" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><P><U>G</U>hi nhận</P></Button></td>
    <td width="16%"><Button name="CmdCancel" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdCancel_onclick()" accesskey="B"><P><U>G</U>ỏ qua</P></Button></td>
    <td width="16%"><Button disabled name="CmdSearch" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdSearch_onclick()" accesskey="M"><P>Tì<u>m</u> kiếm</P></Button></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" style="Font-family:Times New Roman;font-size:12pt;BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: none;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" bordercolor="#111111" bgcolor="#BDD5D0">
  <tr>
    <td width="10%" valign="middle">&nbsp;Mã</td>
    <td width="15%"><input name="TxtMa" value="<%=TaoMa("madoitac","doitac")%>" size="12" maxLength=10 style="FONT-FAMILY:Arial;width:100%" tabindex=1></td>
	<td width="25%" align=center><label for=C1 accesskey="h">T<u>h</u>êm liên tục</label><input type="checkbox" name="CheckAdd" value="ON" checked id=C1></td>
    <td width="10%" align=center>Phone</td>
    <td><input name="TxtPhone" size="33" maxLength=20 style="FONT-FAMILY: Arial;width:100%" tabindex=3></td>
  </tr>
  <tr>
    <td width="10%">&nbsp;Tên</td>
    <td width="40%" colspan=2><input name="TxtTen"  size="33" maxLength=50 style="FONT-FAMILY: Arial;width:100%" tabindex=2></td>
    <td width="10%" align=center>Fax</td>
    <td><input name="TxtFax"  size="33" maxLength=20 style="FONT-FAMILY: Arial;width:100%"></td>
  </tr>
  <tr>
    <td width="10%">&nbsp;Địa chỉ</td>
    <td width="40%" colspan=2><input name="TxtDiachi" size="33" maxLength=255 style="FONT-FAMILY: Arial;width:100%"></td>
    <td width="10%" align=center>E-mail</td>
    <td><input name="TxtEmail"  size="33" maxLength=60 style="FONT-FAMILY: Arial;width:100%"></td>
  </tr>
</Table>
<% else %>		<!-- if CheckAdd<>"ON" -->
  <tr>
	<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin") then	%>
	    <td width="17%"><Button name="CmdAdd" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><U>T</U>hêm</Button></td>
		<%if bComm<>"detail" then %>
			<td width="17%"><Button disabled name="CmdDelete" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><U>X</U>óa</Button></td>
			<td width="17%"><Button disabled name="CmdEdit" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><U>S</U>ửa</Button></td>
		<%else%>
			<td width="17%"><Button name="CmdDelete" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><U>X</U>óa</Button></td>
			<td width="17%"><Button name="CmdEdit" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><U>S</U>ửa</Button></td>
		<%end if%>
		<td width="17%"><Button name="CmdOK" disabled=true style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><P><U>G</U>hi nhận</P></Button></td>
		<td width="16%"><Button name="CmdCancel" disabled=true style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdCancel_onclick()" accesskey="B"><P><U>B</U>ỏ qua</P></Button></td>
		<td width="16%"><Button name="CmdSearch" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdSearch_onclick()" accesskey="M"><P>Tì<u>m</u> kiếm</P></Button></td>
    <%else%>
		<td width="17%"><Button disabled  name="CmdAdd" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><U>T</U>hêm</Button></td>
		<td width="17%"><Button disabled name="CmdDelete" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><U>X</U>óa</Button></td>
		<td width="17%"><Button disabled name="CmdEdit" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><U>S</U>ửa</Button></td>
		<td width="17%"><Button name="CmdOK" disabled=true style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><P><U>G</U>hi nhận</P></Button></td>
		<td width="16%"><Button name="CmdCancel" disabled=true style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdCancel_onclick()" accesskey="B"><P><U>B</U>ỏ qua</P></Button></td>
		<td width="16%"><Button name="CmdSearch" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdSearch_onclick()" accesskey="M"><P>Tì<u>m</u> kiếm</P></Button></td>
	<%end if%>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" style="Font-family:Times New Roman;font-size:12pt;BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: none;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" bordercolor="#111111" bgcolor="#BDD5D0">
	<% if bcomm="detail" then %>
  <tr>
    <td width="10%">&nbsp;Mã</td>
    <td width="15%"><input name="TxtMa" disabled=true  value="<%=bma%>" size="12" maxLength=10 style="FONT-FAMILY: Arial;width:100%"></td>
	<td width="25%" align=center><label for=C1 accesskey="h">T<u>h</u>êm liên tục </label><input type="checkbox" name="CheckAdd" value="ON" disabled id=C1></td>
    <td width="10%" align=center>Phone</td>
    <td><input name="TxtPhone" disabled=true value="<%=bphone%>" size="33" maxLength=20 style="FONT-FAMILY: Arial;width:100%"></td>
  </tr>
  <tr>
    <td width="10%">&nbsp;Tên</td>
    <td width="40%" colspan=2><input name="TxtTen" disabled=true value="<%=bten%>" size="33" maxLength=50 style="FONT-FAMILY: Arial;width:100%"></td>
    <td width="10%" align=center>Fax</td>
    <td><input name="TxtFax" disabled=true value="<%=bfax%>" size="33" maxLength=20 style="FONT-FAMILY: Arial;width:100%"></td>
  </tr>
  <tr>
    <td width="10%">&nbsp;Địa chỉ</td>
    <td width="40%" colspan=2><input name="TxtDiachi" disabled=true value="<%=bdiachi%>" size="33" maxLength=255 style="FONT-FAMILY: Arial;width:100%"></td>
    <td width="10%" align=center>E-mail</td>
    <td ><input name="TxtEmail" disabled=true value="<%=bemail%>" size="33" maxLength=60 style="FONT-FAMILY: Arial;width:100%"></td>
  </tr>
  <%else%>
  <tr>
    <td width="10%" valign="middle">&nbsp;Mã</td>
    <td width="15%"><input name="TxtMa" disabled=true size="12" maxLength=10 style="FONT-FAMILY:Arial;width:100%"></td>
	<td width="25%" align=center><label for=C1 accesskey="h">T<u>h</u>êm liên tục </label><input type="checkbox" name="CheckAdd" value="ON" disabled id=C1></td>
    <td width="10%" align=center>Phone</td>
    <td><input name="TxtPhone" disabled=true size="33" maxLength=20 style="FONT-FAMILY: Arial;width:100%"></td>
  </tr>
  <tr>
    <td width="10%">&nbsp;Tên</td>
    <td width="40%" colspan=2><input name="TxtTen" disabled=true size="33" maxLength=50 style="FONT-FAMILY: Arial;width:100%"></td>
    <td width="10%" align=center>Fax</td>
    <td><input name="TxtFax" disabled=true size="33" maxLength=20 style="FONT-FAMILY: Arial;width:100%"></td>
  </tr>
  <tr>
    <td width="10%">&nbsp;Địa chỉ</td>
    <td width="40%" colspan=2><input name="TxtDiachi" disabled=true size="33" maxLength=255 style="FONT-FAMILY: Arial;width:100%"></td>
    <td width="10%" align=center>E-mail</td>
    <td><input name="TxtEmail" disabled=true size="33" maxLength=60 style="FONT-FAMILY: Arial;width:100%"></td>
  </tr>
  <%end if%>
</Table>
<% end if %>		<!-- end if CheckAdd="ON" -->
<table border="0" style="Font-family:Times new roman;font-size:12pt;BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: none;Border-color:#C0C0C0" WIDTH="100%">
  <tr>
    <td width="100%" colspan="3" bgcolor="#173584">
    <p align="center"><b><font color="#FFFFFF" size="2">DANH SÁCH TỔ CHỨC ĐỐI TÁC</font></b></td>
  </tr>
  <tr  bgcolor="#BDD5D0">
    <td width="15%" align="center"><b>Mã</b></td>
    <td width="60%" align="center"><b>Tên đối tác</b></td>
    <td width="25%" align="center"><b>E-mail</b></td>
  </tr>
  <%	
	If Not Rec.Eof Then
		nRecCount = Rec.RecordCount
		Rec.PageSize = 20
		nPageCount = Rec.PageCount
		If nPage < 1 then
			nPage = 1			
		End If
		if nPage > nPageCount Then
			nPage=nPageCount
		end if
		cnt=(pg-1)*pgsize + 1		    
		STT=1
		rec.AbsolutePage=nPage
		howmanyrecs=0
		do while not Rec.EOF and howmanyrecs<rec.PageSize
			if (cnt/2=int(cnt/2)) then
				color="#eeeecc"
			else
				color="#F8F9D9"
			end if
%>  
  <tr id=mnu_<%=STT%> style="BORDER-RIGHT: #e7e7e7 1px solid; BORDER-TOP: #e7e7e7 1px solid; BORDER-LEFT: #e7e7e7 1px solid; COLOR: #666666; BORDER-BOTTOM: #e7e7e7 1px solid; HEIGHT: 21px; BACKGROUND-COLOR: <%=color%>" 
 onmouseover="javascript:MouseOverMenu('mnu_<%=STT%>')" onmouseout="javascript:MouseOutMenu('mnu_<%=STT%>','<%=color%>')">
    <td width="15%"><font face="Times New Roman"><a style='color:blue;text-decoration: none' href="frmdoitac.asp?page=<%=nPage%>&bma=<%=Rec("Madoitac")%>&bComm=<%="detail"%>">&nbsp;<%=Rec("Madoitac")%></a></font></td>
    <td width="60%"><font face="Times New Roman"><a style='color:blue;text-decoration: none' href="frmdoitac.asp?page=<%=nPage%>&bma=<%=Rec("Madoitac")%>&bComm=<%="detail"%>">&nbsp;<%=Rec("tendoitac")%></a></font></td>
    <td width="25%"><font face="Times New Roman"><a style='color:blue;text-decoration: none' href="frmdoitac.asp?page=<%=nPage%>&bma=<%=Rec("Madoitac")%>&bComm=<%="detail"%>">&nbsp;<%=Rec("email")%></a></font></td>
  </tr>
<%			STT=STT+1
			Rec.MoveNext
			cnt=cnt+1
			howmanyrecs=howmanyrecs+1
		loop
	end if
	rec.Close
	set rec=nothing
	
%>  
</table>
 <!-- Phan trang -->
<br>
<table width="98%" cellspacing=0 cellpadding=0>
<tr>
<% if nPage > 0 and nPageCount >0  then %>  
	<td width="20%"><b>Trang&nbsp; <%=nPage%>/<%=nPageCount%></b></td>
<!-- 	<td width= "80%" align="right">
	<% if nPageCount > 1 then %>    
		Chuyển nhanh tới trang:&nbsp;
		<select name="page" style="width:45;height:23;font-size:8pt" size=1 onchange="javaScript:ChangePage()">
			<% for i = 1 to nPageCount%>	
				<% if bComm<>"search"  then
					strURL="frmdoitac.asp?bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(i) + "&bComm="
				else
					strURL="frmdoitac.asp?bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(i) + "&bComm=search"
				end if %>
				<option value="<%=strURL%>" <%=chkSelected(i, nPage)%>><%=i%></option>
			<% next %>    
		</select>
		</td>                                  
	<% end if %>              -->
<% 'else %>
<% end if %>
<td width= "80%" align="center"><%=Paging(nPage, nPageCount, nRecCount)%></td>
</tr>
</table>
</body>
</form>
</html>
<%
	Conn.Close
	Set Conn=nothing
	set ClsFun=nothing
%>